const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('act_hi_actinst', {
    id: {
      type: DataTypes.STRING(64),
      allowNull: false,
      primaryKey: true,
      field: 'ID_'
    },
    rev: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 1,
      field: 'REV_'
    },
    procDefId: {
      type: DataTypes.STRING(64),
      allowNull: false,
      field: 'PROC_DEF_ID_'
    },
    procInstId: {
      type: DataTypes.STRING(64),
      allowNull: false,
      field: 'PROC_INST_ID_'
    },
    executionId: {
      type: DataTypes.STRING(64),
      allowNull: false,
      field: 'EXECUTION_ID_'
    },
    actId: {
      type: DataTypes.STRING(255),
      allowNull: false,
      field: 'ACT_ID_'
    },
    taskId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      field: 'TASK_ID_'
    },
    callProcInstId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      field: 'CALL_PROC_INST_ID_'
    },
    actName: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'ACT_NAME_'
    },
    actType: {
      type: DataTypes.STRING(255),
      allowNull: false,
      field: 'ACT_TYPE_'
    },
    assignee: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'ASSIGNEE_'
    },
    startTime: {
      type: DataTypes.DATE(3),
      allowNull: false,
      field: 'START_TIME_'
    },
    endTime: {
      type: DataTypes.DATE(3),
      allowNull: true,
      field: 'END_TIME_'
    },
    duration: {
      type: DataTypes.BIGINT,
      allowNull: true,
      field: 'DURATION_'
    },
    deleteReason: {
      type: DataTypes.STRING(4000),
      allowNull: true,
      field: 'DELETE_REASON_'
    },
    tenantId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      defaultValue: "",
      field: 'TENANT_ID_'
    }
  }, {
    sequelize,
    tableName: 'act_hi_actinst',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "ID_" },
        ]
      },
      {
        name: "ACT_IDX_HI_ACT_INST_START",
        using: "BTREE",
        fields: [
          { name: "START_TIME_" },
        ]
      },
      {
        name: "ACT_IDX_HI_ACT_INST_END",
        using: "BTREE",
        fields: [
          { name: "END_TIME_" },
        ]
      },
      {
        name: "ACT_IDX_HI_ACT_INST_PROCINST",
        using: "BTREE",
        fields: [
          { name: "PROC_INST_ID_" },
          { name: "ACT_ID_" },
        ]
      },
      {
        name: "ACT_IDX_HI_ACT_INST_EXEC",
        using: "BTREE",
        fields: [
          { name: "EXECUTION_ID_" },
          { name: "ACT_ID_" },
        ]
      },
    ]
  });
};
